package fr.inria.zvtm.engine;

import jpavlich.cardsorter.action.Experiment;
import jpavlich.cardsorter.action.MoveCard;
import jpavlich.cardsorter.action.MoveCardToTop;
import jpavlich.cardsorter.action.ResourceManager;
import fr.inria.zvtm.glyphs.Glyph;

public class RecordableDragger extends Dragger {

	private Experiment actionManager;
	private ResourceManager resourceManager;
	private VirtualSpace vs;

	public RecordableDragger(View view, VirtualSpace vs,
			Experiment actionManager, ResourceManager rm) {
		super(view);
		this.actionManager = actionManager;
		this.resourceManager = rm;
		this.vs = vs;
	}

	
	
	@Override
	public void startDrag(Glyph g) {
		super.startDrag(g);
		actionManager.execute(new MoveCardToTop(resourceManager.getResourceID(draggedGlyph),
						resourceManager.getResourceID(vs)), false);
	}

	@Override
	public Glyph drag() {
		VCursor c = view.getCursor();
		actionManager.execute(
				new MoveCard(resourceManager.getResourceID(draggedGlyph),
						resourceManager.getResourceID(vs), c.vx - c.pvx, c.vy
								- c.pvy), false);
		return draggedGlyph;
	}

}
